// add element
let set = new Set();
console.log(set);
set.add(1);
console.log(set);
set.add(2).add(3);
console.log(set);

// remove element
set = new Set([1, 2, 3]);
console.log(set,
	set.size,
	set.has(3));
set.delete(3);
console.log(set.has(3),
	set.size,
	set);
set.clear();
console.log(set.size, set);

// build from string
set = new Set('abc');
set.forEach((item) => { console.log(item); });
console.log(set.keys(), set.values(), set.entries());

// convert to array
let s = new Set([1, 2, 3, 4, 5, 3, 2]);
let arr = [...s];
console.log(arr);

// operation
let s1 = new Set([1, 2, 3, 4]);
let s2 = new Set([3, 4, 5, 6]);
let union = new Set([...s1, ...s2]);
console.log(s1.union(s2), s2.union(s1), union);
let intersection = new Set([...s1].filter(x => s2.has(x)));
console.log(s1.intersection(s2), s2.intersection(s1), intersection);
let difference1 = new Set([...s1].filter(x => !s2.has(x)));
console.log(s1.difference(s2), difference1);
let difference2 = new Set([...s2].filter(x => !s1.has(x)));
console.log(s2.difference(s1), difference2);
